package controllers;
import business.SysUser;
import com.shove.web.security.InjectionInterceptor;
import models.sys_menu;
import models.sys_user;
import net.sf.json.JSONObject;
import org.apache.axis.utils.StringUtils;
import org.omg.PortableInterceptor.Interceptor;
import play.Logger;
import play.cache.Cache;
import play.mvc.Before;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Scope;
import sun.rmi.runtime.Log;
import utils.Constants;

import java.io.File;

/**
 * 后台总控制器类
 */
public class BaseController extends Controller {
    /**
     * 脚本注入拦截器
     * @throws Exception
     */
    @Before
    protected static void injectionInterceptor() throws Exception {
        new InjectionInterceptor().run();
        Logger.info(request.url+","+JSONObject.fromObject(params.all()).toString());
    }

    /**
     * 权限判断
     */
    @Before(unless = {
            "FileController.uploadImage",
            "FileController.images" })
    protected static void checkPermission(){
        SysUser.checkLogin();
        //验证权限
        boolean bResult = SysUser.isHavePermission(request.url);
        if(!bResult){
            renderText("no permission access: " +request.url);
        }
    }
}
